﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.DataAccess;
using System.Collections.ObjectModel;
namespace University.Workshop.Business
{
    public class RelationshipsManager
    {
        public Collection<User> Friends { get; private set; }

        public Collection<User> PendingReceived { get; private set; }
        public Collection<User> PendingSend { get; private set; }
        public Collection<User> PeopleNotKnow { get; private set; }
        public Collection<User> All{get;private set;}

        public RelationshipsManager()
        {
            Friends = new Collection<User>();
            PendingReceived = new Collection<User>();
            PendingSend= new Collection<User>();
            PeopleNotKnow= new Collection<User>();
            All = new Collection<User>();
        }


        public void SetAll(Collection<User> copy)
        {
            if (copy != null)
            {

                All.Clear();
                foreach (User userReceived in copy)
                    All.Add(userReceived);
            }
        }
        
        public bool AddPeopleNotKnow(Collection <User> people)
        {
            if (people != null)
            {
                Collection<User> peopleCopy = new Collection<User>();
                if (people != null)
                {
                    foreach (User user in people)
                    {
                        peopleCopy.Add(user);
                    }
                }

                foreach (User user in Friends)
                {
                    peopleCopy.Remove(user);
                }
                foreach (User user in PendingSend)
                {
                    peopleCopy.Remove(user);
                }
                foreach (User user in PendingReceived)
                {
                    peopleCopy.Remove(user);
                }
                foreach (User user in peopleCopy)
                {
                    PeopleNotKnow.Add(user);
                }
                return true;
            }
            return false;
        }
    }
}
